// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.sec.android.app.calculator;

import android.os.Handler;
import android.text.Editable;
import android.view.View;
import android.widget.EditText;
import com.sec.android.widgetapp.calculator.Panel;

// Referenced classes of package com.sec.android.app.calculator:
//            EventHandler, History, HistoryEntry

class EventListener
    implements android.view.View.OnClickListener, android.view.View.OnLongClickListener, com.sec.android.widgetapp.calculator.Panel.OnPanelListener
{

    EventListener()
    {
        mCheck = false;
        mdisCheck = false;
        historyCount = new int[10];
        sb = new StringBuilder();
    }

    private void clearSB()
    {
        int i = sb.length();
        if(i != 0)
            sb.delete(0, i);
    }

    public void onClick(View view)
    {
        mHandler.setFrontText(mHandler.getText());
        view.getId();
        JVM INSTR tableswitch 2130968586 2130968620: default 172
    //                   2130968586 230
    //                   2130968587 469
    //                   2130968588 456
    //                   2130968589 240
    //                   2130968590 391
    //                   2130968591 404
    //                   2130968592 417
    //                   2130968593 443
    //                   2130968594 352
    //                   2130968595 365
    //                   2130968596 378
    //                   2130968597 430
    //                   2130968598 313
    //                   2130968599 326
    //                   2130968600 339
    //                   2130968601 250
    //                   2130968602 300
    //                   2130968603 260
    //                   2130968604 270
    //                   2130968605 220
    //                   2130968606 482
    //                   2130968607 495
    //                   2130968608 508
    //                   2130968609 521
    //                   2130968610 560
    //                   2130968611 547
    //                   2130968612 573
    //                   2130968613 534
    //                   2130968614 280
    //                   2130968615 586
    //                   2130968616 599
    //                   2130968617 612
    //                   2130968618 290
    //                   2130968619 625
    //                   2130968620 638;
           goto _L1 _L2 _L3 _L4 _L5 _L6 _L7 _L8 _L9 _L10 _L11 _L12 _L13 _L14 _L15 _L16 _L17 _L18 _L19 _L20 _L21 _L22 _L23 _L24 _L25 _L26 _L27 _L28 _L29 _L30 _L31 _L32 _L33 _L34 _L35 _L36
_L1:
        if(sb.length() > 0)
            mHandler.insert(sb);
        mHandler.setSelecting(false);
        clearSB();
        mDisplay.setSelection(mHandler.getTextLength());
        return;
_L21:
        mHandler.onEnter();
        continue; /* Loop/switch isn't completed */
_L2:
        mHandler.onClear();
        continue; /* Loop/switch isn't completed */
_L5:
        mHandler.onBackspace();
        continue; /* Loop/switch isn't completed */
_L17:
        mHandler.onParenthesis();
        continue; /* Loop/switch isn't completed */
_L19:
        mHandler.onDecimal();
        continue; /* Loop/switch isn't completed */
_L20:
        mHandler.onPlusMinus();
        continue; /* Loop/switch isn't completed */
_L30:
        mHandler.onFraction();
        continue; /* Loop/switch isn't completed */
_L34:
        mHandler.onAbs();
        continue; /* Loop/switch isn't completed */
_L18:
        sb.append("0");
        continue; /* Loop/switch isn't completed */
_L14:
        sb.append("1");
        continue; /* Loop/switch isn't completed */
_L15:
        sb.append("2");
        continue; /* Loop/switch isn't completed */
_L16:
        sb.append("3");
        continue; /* Loop/switch isn't completed */
_L10:
        sb.append("4");
        continue; /* Loop/switch isn't completed */
_L11:
        sb.append("5");
        continue; /* Loop/switch isn't completed */
_L12:
        sb.append("6");
        continue; /* Loop/switch isn't completed */
_L6:
        sb.append("7");
        continue; /* Loop/switch isn't completed */
_L7:
        sb.append("8");
        continue; /* Loop/switch isn't completed */
_L8:
        sb.append("9");
        continue; /* Loop/switch isn't completed */
_L13:
        sb.append("+");
        continue; /* Loop/switch isn't completed */
_L9:
        sb.append("-");
        continue; /* Loop/switch isn't completed */
_L4:
        sb.append("\327");
        continue; /* Loop/switch isn't completed */
_L3:
        sb.append("\367");
        continue; /* Loop/switch isn't completed */
_L22:
        sb.append("\u221A(");
        continue; /* Loop/switch isn't completed */
_L23:
        sb.append("%");
        continue; /* Loop/switch isn't completed */
_L24:
        sb.append("!");
        continue; /* Loop/switch isn't completed */
_L25:
        sb.append("sin(");
        continue; /* Loop/switch isn't completed */
_L29:
        sb.append("tan(");
        continue; /* Loop/switch isn't completed */
_L27:
        sb.append("cos(");
        continue; /* Loop/switch isn't completed */
_L26:
        sb.append("log(");
        continue; /* Loop/switch isn't completed */
_L28:
        sb.append("ln(");
        continue; /* Loop/switch isn't completed */
_L31:
        sb.append("e^(");
        continue; /* Loop/switch isn't completed */
_L32:
        sb.append("^(2)");
        continue; /* Loop/switch isn't completed */
_L33:
        sb.append("^(");
        continue; /* Loop/switch isn't completed */
_L35:
        sb.append("\u03C0");
        continue; /* Loop/switch isn't completed */
_L36:
        sb.append("e");
        if(true) goto _L1; else goto _L37
_L37:
    }

    public boolean onLongClick(View view)
    {
        mHandler.setSelecting(false);
        boolean flag;
        if(view.getId() != 0x7f04000d)
        {
            flag = false;
        } else
        {
            mHandler.handler.sendEmptyMessage(0);
            flag = true;
        }
        return flag;
    }

    public boolean onPanelClicked(Panel panel)
    {
        mHandler.setSelecting(false);
        mHandler.setLongClick(false);
        if(mPanel.isOpen()) goto _L2; else goto _L1
_L1:
        mPanel.setAniEnd(false);
_L6:
        boolean flag = true;
_L4:
        return flag;
_L2:
        if(mHandler.isDisplayScreen() || mHandler.isHistoryScreen())
            continue; /* Loop/switch isn't completed */
        flag = false;
        if(true) goto _L4; else goto _L3
_L3:
        if(true) goto _L6; else goto _L5
_L5:
    }

    public void onPanelClosed(Panel panel)
    {
        mHandler.setSelecting(false);
        mHandler.setLongClick(false);
        mHandler.goneCursor();
        disText = mDisplay.getText().toString();
        String s = disText.replace("\n", "");
        equal = s.indexOf("=");
        boolean flag = false;
        StringBuilder stringbuilder;
        if(s.length() != 0)
        {
            if(mHistory.mPos == 10)
                flag = true;
            int i;
            if(mHandler.isCheckResult())
                s = "";
            else
            if(equal != -1)
                s = s.substring(0, equal);
        } else
        {
            s = "";
        }
        stringbuilder = new StringBuilder();
        i = ((flag) ? 1 : 0);
        while(i < mHistory.mPos) 
        {
            stringbuilder.append(mHistory.current(i).getBase());
            stringbuilder.append("\n=");
            stringbuilder.append(mHistory.current(i).getEdited());
            String s2;
            if(i == mHistory.mPos - 1)
                s2 = "";
            else
                s2 = "\n\n";
            stringbuilder.append(s2);
            i++;
        }
        int j;
        int k;
        if(s.length() != 0)
        {
            EditText edittext;
            String s1;
            if(stringbuilder.length() == 0)
                s1 = "";
            else
                s1 = "\n\n";
            stringbuilder.append(s1);
            stringbuilder.append(s);
        }
        mHisScreen.setText(mHandler.changeColor(stringbuilder));
        mDisplay.setVisibility(8);
        mHisScreen.setVisibility(0);
        j = mHisScreen.getText().length();
        edittext = mHisScreen;
        if(j == 0)
            k = 0;
        else
            k = j;
        edittext.setSelection(k);
        mHisScreen.requestFocus();
    }

    public void onPanelClosedForConfig()
    {
        mHandler.setSelecting(false);
        mHandler.setLongClick(false);
        mHandler.goneCursor();
        String s = mDisplay.getText().toString().replace("\n", "");
        equal = s.indexOf("=");
        boolean flag = false;
        StringBuilder stringbuilder;
        if(s.length() != 0)
        {
            if(mHistory.mPos == 10)
                flag = true;
            int i;
            if(mHandler.isCheckResult())
                s = "";
            else
            if(equal != -1)
                s = s.substring(0, equal);
        } else
        {
            s = "";
        }
        stringbuilder = new StringBuilder();
        i = ((flag) ? 1 : 0);
        while(i < mHistory.mPos) 
        {
            stringbuilder.append(mHistory.current(i).getBase());
            stringbuilder.append("\n=");
            stringbuilder.append(mHistory.current(i).getEdited());
            String s2;
            if(i == mHistory.mPos - 1)
                s2 = "";
            else
                s2 = "\n\n";
            stringbuilder.append(s2);
            i++;
        }
        int j;
        int k;
        if(s.length() != 0)
        {
            EditText edittext;
            String s1;
            if(stringbuilder.length() == 0)
                s1 = "";
            else
                s1 = "\n\n";
            stringbuilder.append(s1);
            stringbuilder.append(s);
        }
        mHisScreen.setText(mHandler.changeColor(stringbuilder));
        mDisplay.setVisibility(8);
        mHisScreen.setVisibility(0);
        j = mHisScreen.getText().length();
        edittext = mHisScreen;
        if(j == 0)
            k = 0;
        else
            k = j;
        edittext.setSelection(k);
        mHisScreen.requestFocus();
    }

    public void onPanelOpened(Panel panel)
    {
        mHandler.setSelecting(false);
        mHandler.setLongClick(false);
        mHandler.goneCursor();
        int i = mHandler.getCursor(mDisplay, true);
        int j = mHandler.getCursor(mDisplay, false);
        mHisScreen.setVisibility(8);
        mDisplay.setVisibility(0);
        mHisScreen.setText("");
        mPanel.setAniEnd(true);
        if(i != j)
        {
            mDisplay.setSelection(i, j);
            mHandler.showCursor();
            if(j == mHandler.getTextLength())
                mHandler.setSelecting(true);
        } else
        {
            mDisplay.setSelection(mDisplay.getText().length());
        }
        mDisplay.requestFocus();
    }

    void setHandler(EventHandler eventhandler, Panel panel, EditText edittext, EditText edittext1, History history)
    {
        mHandler = eventhandler;
        mPanel = panel;
        mHistory = history;
        mHisScreen = edittext1;
        mDisplay = edittext;
        mDisplay.setRawInputType(0);
        mHisScreen.setRawInputType(0);
    }

    private static String disText;
    int equal;
    int historyCount[];
    boolean mCheck;
    EditText mDisplay;
    EventHandler mHandler;
    EditText mHisScreen;
    History mHistory;
    Panel mPanel;
    boolean mdisCheck;
    private StringBuilder sb;
}
